import datetime as dt


class Util(object):

    @classmethod
    def date_str_to_timestamp(cls,date_str):
        if date_str is None:
            return None
        else:
            return int(dt.datetime.strptime(date_str, "%Y-%m-%d %H:%M:%S").timestamp())

    @classmethod
    def datetime_to_timestamp(cls,date):
        if date is None:
            return None
        else:
            return int(date.timestamp())

    @classmethod
    def timestamp_to_datetime(cls, timestamp):
        if timestamp is None:
            return None
        else:
            return dt.datetime.fromtimestamp(timestamp)